package com.atguigu.flink.chapter05.Transform;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.ConnectedStreams;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.CoMapFunction;

/**
 * TODO
 *
 * @author cjp
 * @version 1.0
 * @date 2021/8/9 10:30
 */
public class Flink08_Union {
    public static void main(String[] args) throws Exception {
        // 0.执行环境
//        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());

        // 1.读取数据
        //  sensor_1,123123213,10
        DataStreamSource<Integer> numDS = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8);
        DataStreamSource<Integer> numDS2 = env.fromElements(11, 22, 33, 44, 55,66, 77, 88);
        DataStreamSource<Integer> numDS3 = env.fromElements(111, 122, 133, 144, 155,166, 177, 188);
        DataStreamSource<Integer> numDS4 = env.fromElements(1111, 1122, 1133, 1144, 1155,1166, 1177, 1188);

        // TODO
        DataStream<Integer> numU = numDS.union(numDS2).union(numDS3).union(numDS4);

        numU.print();

        env.execute();
    }
}

/*
    union: 合并流
        1、 流的数据类型 必须 一致
        2、 可以合并多条流
 */
